﻿@page
@{ Layout = "_Layout"; }

<el-table
  :data="sites"
  style="width: 100%;margin-bottom: 20px;"
  row-key="id"
  default-expand-all
  :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
  <el-table-column prop="siteName" label="站点名称" :sortable="true">
    <template slot-scope="scope">
      <el-badge v-if="scope.row.root" style="margin-top: 10px;" value="主站">
        <el-link :underline="false" type="primary" :href="scope.row.web" target="_blank">{{scope.row.siteName}}</el-link>
      </el-badge>
      <el-link :underline="false" type="primary" v-else :href="scope.row.web" target="_blank">{{scope.row.siteName}}</el-link>
    </template>
  </el-table-column>
  <el-table-column prop="siteDir" label="站点文件夹" width="120" :sortable="true"></el-table-column>
  <el-table-column prop="web" label="站点地址" :sortable="true">
    <template slot-scope="scope">
      <el-link :underline="false" type="primary" :href="scope.row.web" target="_blank">{{scope.row.web}}</el-link>
    </template>
  </el-table-column>
  <el-table-column prop="assetsDir" label="上传文件夹" width="120" :sortable="true"></el-table-column>
  <el-table-column prop="assets" label="上传地址" :sortable="true">
    <template slot-scope="scope">
      <el-link :underline="false" type="primary" :href="scope.row.assets" target="_blank">{{scope.row.assets}}</el-link>
    </template>
  </el-table-column>
  <el-table-column prop="api" label="API地址" :sortable="true">
    <template slot-scope="scope">
      <el-link :underline="false" type="primary" :href="scope.row.api" target="_blank">{{scope.row.api}}</el-link>
    </template>
  </el-table-column>
  <el-table-column align="center" label="操作" width="100">
    <template slot-scope="scope">
      <el-button-group>
        <el-button
          size="mini"
          v-on:click="btnEditClick(scope.row)">修改</el-button>
      </el-button-group>
    </template>
  </el-table-column>
</el-table>

<el-drawer
  v-if="editForm"
  title="修改站点访问地址"
  ref="editPanel"
  :visible.sync="editPanel"
  destroy-on-close
  direction="rtl"
  size="50%">
  <div class="drawer__content">
    <el-form v-on:submit.native.prevent ref="editForm" :model="editForm" size="small" :rules="editRules" label-width="200px">
      <el-form-item label="站点名称">{{ editForm.siteName }}</el-form-item>

      <el-form-item label="站点部署方式">
        <el-radio-group v-model="editForm.isSeparatedWeb">
          <el-radio :label="true">站点独立部署</el-radio>
          <el-radio :label="false">站点与CMS部署在一起</el-radio>
        </el-radio-group>
        <div class="tips">设置站点页面部署方式</div>
      </el-form-item>
      <el-form-item v-if="editForm.isSeparatedWeb" label="独立部署站点访问地址" prop="separatedWebUrl">
        <el-input v-model="editForm.separatedWebUrl"></el-input>
      </el-form-item>

      <el-form-item label="上传文件部署方式">
        <el-radio-group v-model="editForm.isSeparatedAssets">
          <el-radio :label="true">上传文件独立部署</el-radio>
          <el-radio :label="false">上传文件与站点部署在一起</el-radio>
        </el-radio-group>
        <div class="tips">上传文件包含图片、视频、附件等除了HTML页面之外的所有文件</div>
      </el-form-item>
      <el-form-item v-if="editForm.isSeparatedAssets" label="上传文件存储文件夹" prop="assetsDir">
        <el-input v-model="editForm.assetsDir"></el-input>
      </el-form-item>
      <el-form-item v-if="editForm.isSeparatedAssets" label="独立部署上传文件访问地址" prop="separatedAssetsUrl">
        <el-input v-model="editForm.separatedAssetsUrl"></el-input>
      </el-form-item>

      <el-form-item label="API部署方式">
        <el-radio-group v-model="editForm.isSeparatedApi">
          <el-radio :label="true">API独立部署</el-radio>
          <el-radio :label="false">API与CMS部署在一起</el-radio>
        </el-radio-group>
        <div class="tips">设置API部署方式</div>
      </el-form-item>
      <el-form-item v-if="editForm.isSeparatedApi" label="独立部署API访问地址" prop="separatedApiUrl">
        <el-input v-model="editForm.separatedApiUrl"></el-input>
        <div class="tips">“/api”结尾字符串系统将自动添加</div>
      </el-form-item>
      
    </el-form>
    <div class="drawer__footer">
      <el-button type="primary" size="small" v-on:click="btnEditSubmitClick" :loading="editLoading">{{ editLoading ? '提交中 ...' : '确 定' }}</el-button>
      <el-button size="small" v-on:click="btnEditCancelClick">取 消</el-button>
    </div>
  </div>
</el-drawer>

@section Scripts{
<script src="/sitefiles/assets/js/admin/settings/sitesUrl.js" type="text/javascript"></script> }